package com.xzx.mr.order;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author xinzhixuan
 * @version V1.0
 * @date 2019/7/21 22:04
 */
public class OrderReducer extends Reducer<Text, DoubleWritable, Text, DoubleWritable> {
    private DoubleWritable outValue = new DoubleWritable();

    @Override
    protected void reduce(Text key, Iterable<DoubleWritable> values, Context context) throws IOException,
            InterruptedException {
        double price = 0;
        for (DoubleWritable value : values) {
            if (value.get() > price) {
                price = value.get();
            }
        }
        outValue.set(price);
        context.write(key, outValue);
    }
}
